package sc.core.dal.dataobject;

import java.io.Serializable;
import java.util.Iterator;
import java.util.Map;

import org.apache.commons.beanutils.BeanUtils;

public class BaseDO implements Serializable {

	private static final long serialVersionUID = -6534618646736852088L;

	@SuppressWarnings("rawtypes")
	public String toString() {
		try {
			Map props = BeanUtils.describe(this);
			Iterator iProps = props.keySet().iterator();
			StringBuffer retBuffer = new StringBuffer();

			while (iProps.hasNext()) {
				String key = (String) iProps.next();

				// skip false property "class"
				if ("class".equals(key)) {
					continue;
				}

				retBuffer.append(key).append("=[").append(props.get(key))
						.append("]");

				if (iProps.hasNext()) {
					retBuffer.append(", ");
				}
			}

			return retBuffer.toString();
		} catch (Exception e) {
			return super.toString();
		}
	}
}